package com.way.designpatterncodepratice.proxy.other;

import java.lang.reflect.Proxy;

/**
 * @author wayleung
 * @description
 * @date 2020-08-12 09:53:07
 */
public class DynamicProxyDemo {
    public static void main(String[] args) {
        TargetInterface target = new Target();
        MyInvocationHandler dynamicProxyInvocationHandler = new MyInvocationHandler(target);
        TargetInterface proxy = (TargetInterface) Proxy.newProxyInstance(target.getClass().getClassLoader(), target.getClass().getInterfaces(), dynamicProxyInvocationHandler);
        System.out.println(proxy.getClass().getName());
        proxy.sayHello("way");
    }
}
